<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('会员账户')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								会员编号：<input type="text" name="memberId"/>
							</li>

							<li>
								账户类型：
								<select name="accountType" th:with="type=${@dict.getType('member_account_type')}">
								  <option value="">所有</option>
								  <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
								  </option>
								</select>
							</li>

							<li>
								账户编号：<input type="text" name="accountId"/>
							</li>

							<li>
								账户属性：
								<select name="accountAttribute" th:with="type=${@dict.getType('member_account_attribute')}">
								  <option value="">所有</option>
								  <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
								  </option>
								</select>
							</li>

							<li>
								状态：
								<select name="accountAttribute" th:with="type=${@dict.getType('member_account_status')}">
								  <option value="">所有</option>
								  <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
								  </option>
								</select>
							</li>


							<li>
								账户类别:
								<select name="category" th:with="type=${@dict.getType('member_account_category')}">
								  <option value="">所有</option>
								  <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
								  </option>
								</select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('member:memberTrMemberAccount:edit')}]];
        var removeFlag = [[${@permission.hasPermi('member:memberTrMemberAccount:remove')}]];
        var prefix = ctx + "member/memberTrMemberAccount";
        var prefixDetail = ctx + "member/memberTrMemberAccountDetail";
        $(function() {
            var options = {
				url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "会员账户",
		        showExport: true,
		        detailView: true,
				onExpandRow : function(index, row, $detail) {
					initChildTable(index, row, $detail);
				},
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '主键',
					visible: false
				},
				{
					field : 'memberId', 
					title : '会员编号',
					sortable: true
				},
				{
					field : 'originalRequestNo', 
					title : '开户接口请求号',
					sortable: true
				},
				{
					field : 'accountType', 
					title : '账户类型',
					sortable: true,
					formatter: function(value, row, index) {
		                if (value == '101') {
		                	return '<span>对私基本户</span>';
		                } else if (value == '201') {
		                    return '<span>对公基本户</span>';
		                } else if (value == '301') {
		                    return '<span>特约基本户</span>';
		                } 
		            }
				},
				{
					field : 'accountId', 
					title : '账户编号',
					sortable: true
				},
				{
					field : 'accountAttribute', 
					title : '账户属性',
					sortable: true,
					formatter: function(value, row, index) {
		                if (value == '1') {
		                	return '<span>对私</span>';
		                } else if (value == '2') {
		                    return '<span>对公</span>';
		                } 
		            }
				},
				{
					field : 'status', 
					title : '账户状态',
					sortable: true,
					formatter: function(value, row, index) {
		                if (value == '0') {
		                	return '<span>未激活</span>';
		                } else if (value == '1') {
		                    return '<span>正常</span>';
		                } else if (value == '2') {
		                    return '<span>锁定</span>';
		                } else if (value == '3') {
		                    return '<span>止出</span>';
		                } else if (value == '4') {
		                    return '<span>止入</span>';
		                } 
		            }
				},
				{
					field : 'alias', 
					title : '账户别名',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '建立时间',
					sortable: true
				},
				{
					field : 'category', 
					title : '账户类别',
					sortable: true,
					formatter: function(value, row, index) {
		                if (value == 'DPM') {
		                	return '<span>储值账户</span>';
		                } else if (value == 'CREDIT') {
		                    return '<span>信用账户</span>';
		                } 
		            }
				},
				{
					field : 'typeId', 
					title : '类型id',
					sortable: true
				},
				{
					field : 'memo', 
					title : '备注',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
		initChildTable = function(index, row, $detail) {
			var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
    	    $(childTable).bootstrapTable({
    	        url: prefixDetail + "/list",
    	        method: 'post',
    	        sidePagination: "server",
    	        contentType: "application/x-www-form-urlencoded",
    	        queryParams : {
    	        	memberAccId: row.id
				},
    	        columns: [{
					field : 'balance', 
					title : '账户余额'
				},
				{
					field : 'availableBalance', 
					title : '账户可用余额'
				},
				{
					field : 'frozenBalance', 
					title : '账户冻结余额'
				},
				{
					field : 'withdrawBalance', 
					title : '可提现金额，信用账户现金额度'
				},
				{
					field : 'currencyCode', 
					title : '币种'
				}]
    	    });
		};
    </script>
</body>
</html>